package fx.com.service.impl;


import fx.com.entity.User;
import fx.com.exception.NameAndPassordIsNullException;
import fx.com.mapper.UserMapper;
import fx.com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author:yanjizhw@163.com
 * @date:2019/1/17 10:00
 * 描述:
 * @since:1.0.0
 */
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    public List<User> login(String name, String password)  {

        Map<String, String> map = new HashMap();

            map.put("username", name);
            map.put("password", password);
            List<User> users = userMapper.selectByNameAndPassword(map);
            return users;

    }
}
